From ff0eaa63f76f6ea68f5313a0586d08422284a168 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Tue, 20 Feb 2007 20:59:34 +0000 Subject: [PATCH] Fix discard filter bug. Remove waypt_free() from any_route_del_wpt(). git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@2680 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/discard.c | 34 ++++++++++++++++++++++------------ gpsbabel/position.c | 2 +- gpsbabel/route.c | 1 - gpsbabel/smplrout.c | 1 + gpsbabel/trackfilter.c | 6 ++++-- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/gpsbabel/discard.c b/gpsbabel/discard.c index 1b69c8c86..d8f1942c5 100644 --- a/gpsbabel/discard.c +++ b/gpsbabel/discard.c @@ -28,6 +28,8 @@ static char *vdopopt = NULL; static char *andopt = NULL; static double hdopf; static double vdopf; +static gpsdata_type what; +static route_head *head; static arglist_t fix_args[] = { @@ -62,35 +64,43 @@ fix_process_wpt(const waypoint *wpt) del = delh || delv; if (del) { - waypt_del(waypointp); + switch(what) { + case wptdata: + waypt_del(waypointp); + break; + case trkdata: + track_del_wpt(head, waypointp); + break; + case rtedata: + route_del_wpt(head, waypointp); + break; + default: + return; + } waypt_free(waypointp); } } static void -fix_process_track(const route_head *trk) +fix_process_head(const route_head *trk) { - waypoint * waypointp; - queue *elem, *tmp; - - QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) { - waypointp = (waypoint *)elem; - - fix_process_wpt(waypointp); - } + head = (route_head *)trk; } static void fix_process(void) { // Filter waypoints. + what = wptdata; waypt_disp_all(fix_process_wpt); // Filter tracks - track_disp_all(fix_process_track, NULL, NULL); + what = trkdata; + track_disp_all(fix_process_head, NULL, fix_process_wpt); // And routes - route_disp_all(fix_process_track, NULL, NULL); + what = rtedata; + route_disp_all(fix_process_head, NULL, fix_process_wpt); } diff --git a/gpsbabel/position.c b/gpsbabel/position.c index 3914963ab..42247d249 100644 --- a/gpsbabel/position.c +++ b/gpsbabel/position.c @@ -117,7 +117,6 @@ position_runqueue(queue *q, int nelems, int qtype) switch (qtype) { case wptdata: waypt_del(comp[i]); - waypt_free(comp[i]); break; case trkdata: track_del_wpt(cur_rte, comp[i]); @@ -128,6 +127,7 @@ position_runqueue(queue *q, int nelems, int qtype) default: break; } + waypt_free(comp[i]); } } } diff --git a/gpsbabel/route.c b/gpsbabel/route.c index 39130834f..d6c6a3880 100644 --- a/gpsbabel/route.c +++ b/gpsbabel/route.c @@ -205,7 +205,6 @@ static void any_route_del_wpt( route_head *rte, waypoint *wpt, int *ct) { dequeue( &wpt->Q ); - waypt_free( wpt ); rte->rte_waypt_ct--; if ( ct ) (*ct)--; } diff --git a/gpsbabel/smplrout.c b/gpsbabel/smplrout.c index e82452199..f3088766c 100644 --- a/gpsbabel/smplrout.c +++ b/gpsbabel/smplrout.c @@ -271,6 +271,7 @@ routesimple_tail( const route_head *rte ) } route_del_wpt( (route_head *)(void *)rte, (waypoint *)(void *)(xte_recs[i].intermed->wpt)); + waypt_free((waypoint *)(void *)(xte_recs[i].intermed->wpt)); if ( xte_recs[i].intermed->prev ) { xte_recs[i].intermed->prev->next = xte_recs[i].intermed->next; diff --git a/gpsbabel/trackfilter.c b/gpsbabel/trackfilter.c index 6b209b8cd..3b3a1cbcf 100644 --- a/gpsbabel/trackfilter.c +++ b/gpsbabel/trackfilter.c @@ -428,6 +428,7 @@ trackfilter_merge(void) wpt = (waypoint *)elem; buff[j++] = waypt_dupe(wpt); track_del_wpt(track, wpt); + waypt_free(wpt); } if (track != master) /* i > 0 */ track_del_head(track); @@ -660,8 +661,8 @@ trackfilter_split(void) } if (curr != NULL) { - wpt = waypt_dupe(buff[j]); - track_del_wpt(master, buff[j]); + wpt = buff[j]; + track_del_wpt(master, wpt); track_add_wpt(curr, wpt); buff[j] = wpt; } @@ -823,6 +824,7 @@ trackfilter_range(void) /* returns number of track points left after filtering if ((wpt->creation_time < start) || (wpt->creation_time > stop)) { track_del_wpt(track, wpt); + waypt_free(wpt); dropped++; } } -- 2.30.2